package insight;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author huu
 * @create 2025-08-26-10:01
 * @description: 享元模式，典型的Integer
 */
public class Main {
    public static void main(String[] args) {
        //享元会缓存一部分数据，需要时可以直接调用，而未来存的例如下面的1000会新建而不是复用
        Integer a = 1;
        Integer b = 1;
        //下面的代码真正的执行为Integer c = Integer.valueOf(1000);,可以去看看源码
        Integer c = 1000;
        Integer d = 1000;
        System.out.println(a == b); //true
        System.out.println(c == d); //false

        //ThreadPool线程池
        //ThreadPoolExecutor executor = new ThreadPoolExecutor(5, 10, 2000, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<>(5));

        //连接池
        //ConnectionPool pool = new ConnectionPool(5);
    }
}
